@model ProductTagSearchModel

@{
    //page title
    ViewBag.Title = T("Admin.Catalog.ProductTags").Text;
    //active menu item (system name)
    Html.SetActiveMenuItemSystemName("Product tags");
}

<form asp-controller="Product" asp-action="ProductTags" method="post" id="product-tags-form">
    <div class="content-header clearfix">
        <h1 class="pull-left">
            @T("Admin.Catalog.ProductTags")
        </h1>
        <div class="pull-right">
            &nbsp;
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.ProductTagListButtons })
        </div>
    </div>

    <div class="content">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "product-tags-grid",
                        UrlRead = new DataUrl("ProductTags", "Product", null),
                        UrlDelete = new DataUrl("ProductTagDelete", "Product", null),
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(ProductTagModel.Name))
                            {
                                Title = T("Admin.Catalog.ProductTags.Fields.Name").Text,
                                Width = "300"
                            },
                            new ColumnProperty(nameof(ProductTagModel.ProductCount))
                            {
                                Title = T("Admin.Catalog.ProductTags.Fields.ProductCount").Text,
                                Width = "150",
                                ClassName =  NopColumnClassDefaults.CenterAll
                            },
                            new ColumnProperty(nameof(ProductTagModel.Id))
                            {
                                Title = T("Admin.Common.Edit").Text,
                                Width = "100",
                                ClassName =  NopColumnClassDefaults.Button,
                                Render = new RenderCustom("renderColumnEdit")
                            },
                            new ColumnProperty(nameof(ProductTagModel.Id))
                            {
                                Title = T("Admin.Common.Delete").Text,
                                Width = "100",
                                Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
                                ClassName =  NopColumnClassDefaults.Button
                            }
                        }
                    })

                    <script>
                        function renderColumnEdit(data, type, row, meta) {
                            return '<button onclick=\"javascript:OpenWindow(\'@Url.Content("~/Admin/Product/EditProductTag/")' + data + '?btnId=btnRefresh&formId=product-tags-form\', 800, 320, true); return false;\" class="btn btn-default"><i class="fa fa-pencil"></i>@T("Admin.Common.Edit")</button>';
                        }
                    </script>
                    
                    <input type="submit" id="btnRefresh" style="display: none" />
                    <script>
                        $(document).ready(function() {
                            $('#btnRefresh').click(function() {
                                //refresh grid
                                updateTable('#product-tags-grid');

                                //return false to don't reload a page
                                return false;
                            });
                        });
                    </script>
                </div>
            </div>
        </div>
    </div>
</form>